package #(package);

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.jfinal.plugin.activerecord.Page;
import net.cmkj.pm.common.model.DataGridModel;
import net.cmkj.pm.common.model.InvokeResult;
import net.cmkj.pm.bean.#(className);
import net.cmkj.pm.util.DataGridModelUtils;

/**
 * #(className) service
 * 业务逻辑处理
 * 
 */
public class #(className)Service {

	private static Logger log = LogManager.getLogger(#(className)Service.class);
	
	public static final #(className)Service service = new #(className)Service();
	private final #(className) dao = #(className).dao;
	
	/**
	 * 获取列表
	 * @param pageNumber
	 * @param pageSize
	 * @param name
	 * @param status
	 * @return
	 */
	public DataGridModel getList(int pageNumber, int pageSize, String name, Integer status, String orderbyStr) throws Exception {
		log.info("获取列表");
		Page<#(className)> pageInfo = dao.paginate(pageNumber, pageSize, name, status, orderbyStr);
		DataGridModel result = DataGridModelUtils.toDataGridView(pageInfo);
		return result;
	}
	
	/**
	 * 获取对象
	 * @param id
	 * @return
	 */
	public #(className) findById(int id) throws Exception {
	    log.info("获取对象");
		return dao.findById(id);
	}
	
	/**
	 * 对象保存
	 * @param #(classNameSmall)
	 * @return
	 */
	public InvokeResult save(#(className) #(classNameSmall)) throws Exception {
		log.info("对象保存");
		return dao.save(#(classNameSmall));
	}
	
	/**
	 * 对象删除
	 * @param ids
	 * @return
	 */
	public InvokeResult deleteByIds(String ids) throws Exception{
		log.info("对象删除");
    	return dao.deleteByIds(ids);
	}
	
	/**
	 * 修改对象状态
	 * @param ids
	 * @return
	 */
	public InvokeResult setStatus(String ids, Integer status) throws Exception{
		log.info("对象状态变更");
		return dao.setStatus(ids, status);
	}
	
}